﻿using BookingSystemModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.ScheduleView;

namespace Booking_System.User_Controls
{
    /// <summary>
    /// Interaction logic for UCManageBooking.xaml
    /// </summary>
    public partial class UCManageBooking : UserControl
    {
        private Subscription subscription = null;
        private Boolean canContinue = true;

        public UCManageBooking()
        {
            InitializeComponent();
            subscription = new Subscription();

            this.DataContext = new MyViewModel();
        }

        private void RadTabControl_SelectionChanged_1(object sender, Telerik.Windows.Controls.RadSelectionChangedEventArgs e)
        {
            //MessageBox.Show(((Telerik.Windows.Controls.RadTabItem)e.AddedItems[0]).Header.ToString());
            int index = TabControl.SelectedIndex;
            if(index == 0)
                Title.Content = "Høli og tíðarskeið";
            else if (index == 1)
                Title.Content = "Kundi, umboð og virkir";
            else if (index == 2)
                Title.Content = "Áset tænastur fyri høli/r";
        }

        private void Continue_Click(object sender, RoutedEventArgs e)
        {
            Telerik.Windows.Controls.RadTabItem rti = TabControl.SelectedItem as Telerik.Windows.Controls.RadTabItem;
            if (canContinue)
            {
                TabControl.SelectedIndex++;
                rti.IsEnabled = true;
            }
        }

        private void Schedule1_AppointmentCreated(object sender, Telerik.Windows.Controls.AppointmentCreatedEventArgs e)
        {

        }

        public class MyViewModel
        {
            public MyViewModel()
            {
                this.resourceTypes = this.GenerateResourceTypes();
                this.appointments = new ObservableCollection<Appointment>();
            }

            private ObservableCollection<Appointment> appointments;
            private ObservableCollection<ResourceType> resourceTypes;
            public ObservableCollection<Appointment> Appointments
            {
                get
                {
                    return this.appointments;
                }
                set
                {
                    this.appointments = value;
                }
            }
            public ObservableCollection<ResourceType> ResourcesTypes
            {
                get
                {
                    return this.resourceTypes;
                }
                set
                {
                    this.resourceTypes = value;
                }
            }

            private ObservableCollection<ResourceType> GenerateResourceTypes()
            {
                ObservableCollection<ResourceType> result = new ObservableCollection<ResourceType>();

                ResourceType roomType = new ResourceType("Room");
                Resource room102 = new Resource("Room 102");
                Resource room203 = new Resource("Room 203");
                Resource room406 = new Resource("Room 406");
                roomType.Resources.Add(room102);
                roomType.Resources.Add(room203);
                roomType.Resources.Add(room406);

                ResourceType speakerType = new ResourceType("Speaker");
                Resource tomSpeaker = new Resource("Tom");
                Resource peterSpeaker = new Resource("Peter");
                speakerType.Resources.Add(tomSpeaker);
                speakerType.Resources.Add(peterSpeaker);

                result.Add(roomType);
                result.Add(speakerType);
                return result;
            }
        }


    }
}
